/* db */
var dbs = new HashMap();

function addDb(db) {
	dbs.put(db.name, db);
}

function getDb(name) {
	return dbs.get(name);
}

function newDbDataSource(user, pwd, url, jdbcClassName) {
	var dataSource = new ComboPooledDataSource();
	//
	dataSource.setDriverClass(jdbcClassName);
	dataSource.setJdbcUrl(url);
	dataSource.setUser(user);
	dataSource.setPassword(pwd);
	//
	dataSource.setAcquireIncrement(5);
	dataSource.setIdleConnectionTestPeriod(3000);
	dataSource.setCheckoutTimeout(3000);
	dataSource.setInitialPoolSize(5);
	dataSource.setMaxPoolSize(20);
	dataSource.setMinPoolSize(5);
	dataSource.setMaxStatements(5);
	dataSource.setMaxStatementsPerConnection(0);
	dataSource.setMaxIdleTime(30000);
	dataSource.setBreakAfterAcquireFailure(false);
	dataSource.setAcquireRetryAttempts(0);
	return dataSource;
}

addDb(new Db("main", newDbDataSource("sa", "sa", "jdbc:h2:d:/gameh2db/game",
		"org.h2.Driver")));
